package cn.springspace.kotlinappclient

import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.runApplication
import org.springframework.context.support.beans
import org.springframework.web.reactive.function.client.WebClient
import java.util.*

@SpringBootApplication
class KotlinAppClientApplication

data class Book(val name: String, val author: String, val publish: Date)

fun main(args: Array<String>) {
    runApplication<KotlinAppClientApplication>(*args){
        addInitializers(
                beans{
                    bean{
                        WebClient.builder()
                                .baseUrl("http://localhost:8080/")
                                .build()
                                .get()
                                .uri("books")
                                .retrieve()
                                .bodyToFlux(Book::class.java)
                                .subscribe{println(it)}
                    }
                }
        )
    }
}
